<?php


namespace app\admin\controller\setup;


use app\common\controller\Backend;
use app\Request;

/**
 * Notes: 运费规则 控制器
 * DateTime: 2021/05/07 10:59
 * @Author: gxa
 * Class PostageRules
 * @package app\mch\controller\store
 */
class PostageRules extends Backend
{
    /**
     * @var $postageRulesService \app\admin\service\PostageRules
     */
    protected $postageRulesService = null;

    /**
     * Notes:初始化
     * DateTime 2021/5/7 17:43
     * @Author Hunter
     */
    protected function initialize()
    {
        parent::initialize();
        $this->postageRulesService = new \app\admin\service\PostageRules();
    }

    /**
     * Notes:列表
     * DateTime 2021/5/7 17:43
     * @Author Hunter
     * @return \think\response\Json
     */
    public function index()
    {
        return $this->postageRulesService->getList();
    }

    /**
     * Notes:添加
     * DateTime 2021/5/7 17:43
     * @Author Hunter
     * @param Request $request
     * @return \think\response\Json
     */
    public function add(Request $request)
    {
        $param = $request->param();
        return $this->postageRulesService->createBy($param);
    }

    /**
     * Notes:编辑
     * DateTime 2021/5/7 17:36
     * @Author Hunter
     * @return \think\response\Json
     */
    public function edit(Request $request)
    {
        $id = $request->param('id');
        $param = $request->param();
        return $this->postageRulesService->updateBy($id, $param);
    }

    /**
     * Notes:删除
     * DateTime 2021/5/7 17:55
     * @Author Hunter
     * @param Request $request
     * @return \think\response\Json
     */
    public function delete(Request $request)
    {
        $id = $request->param('id');
        return $this->postageRulesService->delete($id);
    }
}